package jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class Demo7 {
    public static void main(String[] args) {
        try(Connection connection = DEUtil.getConnection()) {
            Statement statement = connection.createStatement();
            String sql = "SELECT COUNT(*) AS count,AVG(salary) AS avg_sal FROM teacher";
            ResultSet num = statement.executeQuery(sql);
            while (num.next()){
                int count = num.getInt("count");
                double avg_sal = num.getDouble("avg_sal");
                System.out.println(count+" "+avg_sal);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
